public class Solution1208 {
    public int equalSubstring(String s, String t, int maxCost) {
        int j=0;
        int cur=0;
        int max=0;
        for (int i=0;i<s.length();i++){
            cur=cur+Math.abs(s.charAt(i)-t.charAt(i));
            while (j<=i && cur>maxCost){
                cur=cur-Math.abs(s.charAt(j)-t.charAt(j));
                j++;
            }
            max=Math.max(max,i-j+1);
        }
        return max;
    }

    public static void main(String[] args) {
        System.out.println(new Solution1208().equalSubstring("abcd","bcdf",3));
    }
}
